package com.go.manaservice.service.impl;

import com.go.manaservice.entity.TblManagement;
import com.go.manaservice.entity.vo.ManagmentQuery;
import com.go.manaservice.mapper.Management;
import com.go.manaservice.service.ManagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author ZhengYuXiang
 * @version 1.0
 * @date 2021/11/25 1:12 上午
 */
@Service
public class ManagementServiceImpl implements ManagementService {
    @Autowired
    private Management management;

    @Override
    public boolean addManagement(TblManagement tblManagement) {
        tblManagement.setManaCreate(new Date());
        tblManagement.setManaModify(new Date());
       if (management.addManagement(tblManagement)>0){
           return true;
       }
        return false;
    }

    @Override
    public boolean updateManagement(TblManagement tblManagement) {
        tblManagement.setManaModify(new Date());
        int i = management.updateManagement(tblManagement);
        if (i>0){
            return true;
        }else {
            return false;
        }

    }

    @Override
    public List<TblManagement> list(ManagmentQuery managmentQuery) {

        return management.selectMana(managmentQuery);
    }

    @Override
    public TblManagement findManagementOne(Integer id) {
        TblManagement managementOne = management.findManagementOne(id);
        if (managementOne!=null){
            return managementOne;
        }
       return null;
    }

    @Override
    public int selectManaCount(ManagmentQuery managmentQuery) {
        Integer i = management.selectManaCount(managmentQuery);
        return i;
    }

    @Override
    public boolean deleteManagementS( Map<String, Object> map ) {
       if (management.deleteManagement(map)>0){
           return true;
       }
        return false;
    }
}

